using Basis;
using NL.AdreesableAsset;
using UnityEngine;
namespace NL.Advanced
{
    public partial class Attacker
    {
        // 发球弹道特效 地址模板
        static string URL_OF_ORB_FLY(AttackEffect ae) => $"Orb_Fly_{ae.ToString()}";

        // 发球死亡特效 地址模板
        static string URL_OF_ORB_DEAD(AttackEffect ae) => $"Orb_Dead_{ae}";

        // 发球死亡特效 地址模板
        static string URL_OF_ORB_SPUT(AttackEffect ae) => $"Orb_Sput_{ae}";

        GameObject _OrbFlying;
        void _AddOrbFlying()
        {
            return;
            if (EffectMode == AttackEffect.None) return;

            var url = CombatSetting_Orb.GetUrl_Flying(EffectMode, Orbsuffix);
            // var ob = CombatSetting_Orb.GetOrb_Flying(EffectMode, Orbsuffix);

            if (string.IsNullOrEmpty(url)) return;

            AA.LOAD<GameObject>(url, (w, ob) =>
            {
                if (ob != null)
                    _OrbFlying = BPoolMan.POOL["ORB_FLY"].Create(ob, transform);
            }, gameObject);
        }
        protected GameObject _AddOrdForTarget(GameObject who)
        {
            if (who == null) return null;
            var url = CombatSetting_Orb.GetUrl_Dead(EffectMode, Orbsuffix);

            if (string.IsNullOrEmpty(url)) return null;

            var mod = AA.LoadAndWait(url);
            if (mod == null) return null;

            var _Orb = BPoolMan.POOL["ORB_DEAD"].Create(mod, who.transform);

            return _Orb;
        }
        GameObject _AddOrdDead()
        {
            return null;
            var url = CombatSetting_Orb.GetUrl_Dead(EffectMode, Orbsuffix);

            if (string.IsNullOrEmpty(url)) return null;

            var mod = AA.LoadAndWait(url);
            if (mod != null) return null;

            var _Orb = BPoolMan.POOL["ORB_DEAD"].Create(mod);

            return _Orb;
        }


        protected virtual void _DoIce(ICombatOwner who, float _factor = 1)
        {
            //添加目标特效
            var one = _AddOrdForTarget(who.gameObject);



            //0,-0.5,6  减速点数;减速因数;持续时间.
            var delt = ((nill)Data).AsVector(NLConst.CHAR_INNER);
            if (delt.z > 0)
            {
                who.ADDBuff($"speed={delt.x}{NLConst.CHAR_INNER}{delt.y}", delt.z);
            }
            // 死亡法球增加
            //var orb = _AddOrdDead();


            if (CombatSetting.LOGable)
                LOG.Add($"[Attacker._DoIce]{(_CombatOwner != null ? _CombatOwner.UDD : 0)}->{who.UDD}:{delt}");

        }

        protected virtual void _DoFire(ICombatOwner who, float _factor = 1)
        {
            //添加目标特效
            var one = _AddOrdForTarget(who.gameObject);


            var delt = ((nill)Data).AsVector(NLConst.CHAR_INNER);


            // 死亡法球增加
            var orb = _AddOrdDead();

            if (CombatSetting.LOGable)
                LOG.Add($"[Attacker._DoFire]{(_CombatOwner != null ? _CombatOwner.UDD : 0)}->{who.UDD}:{delt}");
        }

        protected virtual void _DoBomb(ICombatOwner who, float _factor = 1)
        {
            return;
            //添加目标特效
            var one = _AddOrdForTarget(who.gameObject);


            // 死亡法球增加
            var orb = _AddOrdDead();
            if (orb == null) return;


            //数据结构 ... 200,0.2,5   爆炸伤害点数,伤害因数,伤害范围.
            var dataarr = ((nill)Data).AsVector(NLConst.CHAR_INNER);

            float range = dataarr.z > 0 ? dataarr.z : 0;

            //合成攻击力

            ATT att = _CombineAttData(who, default(AttackerInfo));



            orb.transform.position = who != null ? who.transform.position : transform.position;
            var bb = orb.GetComponent<BB>()?.SetCombatOwner(_CombatOwner, 1);

            if (bb != null && bb.AllowSkillPropertyReSize)
            {
                bb.SetSize(range);
            }

            orb.gameObject.GETComponent<Attacker>()?.SetAvliableCamp(AvliableCamp).SetDataSource(DataSource).SetData(Data);
        }


        protected virtual void _DoDizz(ICombatOwner who, float _factor = 1)
        {
            //添加目标特效
            var one = _AddOrdForTarget(who.gameObject);


            //0,-0.5,6  减速点数;减速因数;持续时间.
            var delt = ((nill)Data).AsFloatDefault(0);
            //who.AddBuff($"speed={0}{NLConst.CHAR_INNER}{-1}", delt);
            who.ADDBuff(ObjState.ActionNo, delt);

            // 死亡法球增加
            //var orb = _AddOrdDead();

            if (CombatSetting.LOGable)
                LOG.Add($"[Attacker._DoDizz]{(_CombatOwner != null ? _CombatOwner.UDD : 0)}->{who.UDD}:{delt}");
        }

        protected virtual void _DoSput(ICombatOwner who, float _factor = 1)
        {

        }

    }
}

